#ifndef GAME_H
#define GAME_H
#include <iostream>
#include <string>
#include "Board.h"
#include <vector>
#include <sstream>
#include <utility>
#include <time.h>
#include <cstdlib>

class Game
{
    public:
        Game(); /**< Constructor for the Game class */
        virtual ~Game(); /**< Virtual destructor for the Game class */
        int getPlayerTurn () const; /**< Returns the player who's turn it is */
        void startGame(); /**< Starts a new game */
        void endGame(int winner); /**< Wraps up the current game (someone won) */
        /**
            Moves a player on the board
            @param[in] from From location
            @param[in] to To location
        */
        void makeMove(Point from, Point to);
        /**
            Moves a player on the board SILENTLY
            @param[in] from From location
            @param[in] to To location
        */
        void makeSilentMove(Point from, Point to);
        bool undoMove(); /**< Undos a player's move */
        void printBoard() const; /** Gateway function to board's printBoard() function */
        // Virtual functions
        /**
            Returns a vector with all player's legal moves
            @param[in] p_pieces All pieces on the board
            @param[in] collectPoints All legal moves
        */
        virtual void legalMoves(std::vector<Point>& p_pieces, std::vector<MyPair>& collectPoints) = 0;
        /**
            Decides whether some player has reached terminal state (won the game)
            @returns Player who reached terminal state, otherwise -1
        */
        virtual int terminalState() = 0;
        /**
            Name of the game
            @returns Name of the game
        */
        virtual std::string getName() const = 0;
        virtual void go() = 0; /**< Makes a move depending on level */
        int evaluate(); /**< Evaluate current state */
        int MiniMax(State s, Point& from, Point& to, int depth); /**< MiniMax recursive algorithm */
        std::vector<Point> arrayOfPoints(); /**< Return vector of Points */
        // Getters & Setters
        int getRound() const; /**< Returns the round */
        void incRound(); /**< Increments the round */
        std::string getLevel() const; /**< Gets the current game level */
        void setLevel(std::string l); /**< Sets the current game level */
        bool isGameStarted() const; /**< Returns whether the game has started */
    protected:
        bool m_gameStarted;
        int m_round; /**< Variable for game rounds */
        std::vector<State> m_allMoves; /**< Vector with the game board states */
        Board* m_board; /**< Pointer to the game board */
        std::string m_level; /**< Current level */
};

#endif // GAME_H
